<?php
	session_start();
	require('../Model/mysql.php');
	require('../host_config.php');
	error_reporting(E_ALL);
	if (!isset($_SESSION['username'])) {
		echo "<script language='javascript'>";
        echo "alert('You have no permission to read this page!');";
        echo "history.back();";
        echo "</script>";
        header("location:../login.php");
    }else {
    	$mysql = new MySQL();
    	$link = $mysql->connect($mysql_host, $mysql_user, $mysql_passwd, $mysql_db);
		$u_id = $_GET['id'];
		$u_id = mysql_real_escape_string($u_id);
		$sql = "SELECT `shopname` FROM `LoginUser` WHERE `loginid` = '$u_id'";
		$str = $mysql->query_row($sql, $link);
		
		$sql = "SELECT shopid FROM Shops WHERE fullname = '$str[0]'";
		$result = mysql_query($sql, $link) or die("Execute SQL command failed!");
		$number = mysql_num_fields($result);
    		$row = mysql_fetch_row($result);
		//if ($row != NULL) {
			header("location:test.php?id=$row[0]");
		//}else{
			//header("location:main.php");
		//}
	}
?>
